package com.bruce.practice.thread;

import java.util.Timer;
import java.util.TimerTask;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * @author luotuan
 * @Description
 * @create 2020-05-19 15:35
 **/
public class TimerTest {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new testTask(),1);
        SECONDS.sleep(1);
        timer.schedule(new testTask(),1);
        SECONDS.sleep(5);
    }
}
class testTask extends TimerTask{

    @Override
    public void run() {
        throw new RuntimeException("发生了异常");
    }
}
